/**
 * WordSetImport.java [V 1.0.0]
 * classes : org.xiaocq.wordsgod.io.WordSetImport
 * xiaocq Create at 2012-6-23 下午9:30:42
 */
package com.xiaocq.wordsgod.io;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.content.Context;

/**
 * org.xiaocq.wordsgod.io.WordSetImport
 * @author Mystory
 * Create at 2012-6-23 下午9:30:42
 */
public class FileIOHelper {
	private Context context;
	private String encoding = "UTF-8";
	
	public FileIOHelper(Context context){
		this.context = context;
	}
	
	/**
	 * 获得一个关于assets文件中文件的缓冲读入流
	 * @param fileName
	 * @return
	 * @throws IOException
	 */
	public BufferedReader getBufferedReaderFromAssets(String fileName) throws Exception{
		BufferedReader reader = wrapStreamToBuffer(context.getAssets().open(fileName));
		
		return reader;
	}
	
	private BufferedReader wrapStreamToBuffer(InputStream inputStream) throws Exception{
		return new BufferedReader(new InputStreamReader(inputStream, encoding));
	}
	
}
